Configuration
Settings are read from (later sources win):
- the
mknodesentry of thepluginslist inmkdocs.yml(kept for existing sites), [tool.mknodes]inpyproject.toml(preferred,-and_are interchangeable),- CLI options (
--build-fn,--repo-url,--clone-depth,--generated-dir, …).
Without any settings, the default website gets generated.
[tool.mknodes]
build-fn = "docs/build.py:build"
show-page-info = true
global-resources = false
strict = true # fail on build diagnostics (failed nodes / blocks, broken fences, references)
Note
MkNodes writes HTML template overrides (announcement bars, per-page resources, the error page, …) into the theme
custom_dir(default:overrides). That folder must be placed outside of thedocs/dir. Generated files are listed in a.gitignoreinside the folders they get written to, hand-written files are never overwritten.
Available settings:
class GeneratorSettings
Settings for generating a website from a MkNodes build function.
build_fn
build_fn: str = paths.DEFAULT_BUILD_FN
Build function (module:callable, path/file.py:callable, module:Class.method).
clone_depth
clone_depth: int = 100
Clone depth for remote repositories.
config_file
config_file: pathlib.Path | None = None
The site config the generated config inherits from (mkdocs.yml).
docs_dir
docs_dir: str | None = None
Docs folder (default: docs_dir of the site config, else docs).
docsify
docsify: dict[str, Any] = dataclasses.field(default_factory=dict)
Extra window.$docsify options for the docsify engine (deep-merged into the
generated ones, e.g. themeColor, subMaxLevel).
flavor
flavor: str | None = None
Markdown flavour of the generated pages (material, github, mdbook, myst).
Defaults to the flavour of the engine: material for zensical and mkdocs,
mdbook for mdbook, github for markdown and docsify, myst for sphinx.
generated_config
generated_config: str = GENERATED_CONFIG
Filename of the generated site config (relative to the project dir).
generated_config_path
generated_config_path: pathlib.Path
generated_dir
generated_dir: str | None = None
Folder to write generated pages into (default: docs_dir).
If it differs from docs_dir, hand-written pages get mirrored into it and it becomes
the docs dir of the generated config. For mdbook: the book folder (default book),
for sphinx: the Sphinx source folder (default sphinx), for docsify: the site
folder (default: site_dir).
global_resources
global_resources: bool = True
Put CSS / JS into the site config instead of per-page template blocks.
input_store
input_store: InputStore
The store for external inputs (configured lock file / mode), one per settings.
Shared by the generator (nodes) and the writer (page icons).
inputs_mode
inputs_mode: str = 'live'
How external inputs get resolved: live (lock file first, fetch + add missing
ones), refresh (fetch all again, prune unused lock entries) or offline (lock
file only, missing inputs are an error).
jinja_block_end_string
jinja_block_end_string: str | None = None
jinja_block_start_string
jinja_block_start_string: str | None = None
jinja_engine
jinja_engine: str | None = None
Template engine for the Jinja templates: jinja2 or minijinja (needs the
minijinja extra). Default: the MKNODES_JINJA_ENGINE environment variable, else
jinja2. See jinjarope.engine for the differences.
jinja_extensions
jinja_extensions: list[str] | None = None
jinja_loaders
jinja_loaders: list[dict[str, Any]] | None = None
jinja_variable_end_string
jinja_variable_end_string: str | None = None
jinja_variable_start_string
jinja_variable_start_string: str | None = None
kwargs
kwargs: dict[str, Any] = dataclasses.field(default_factory=dict)
Keyword arguments for the build function (pages for the default build function).
lock_file
lock_file: str = 'mknodes.lock'
Lock file for external inputs (icons, licenses, LLM texts), relative to the project
dir. Empty: no lock file. See mknodes.inputs.
lock_path
lock_path: pathlib.Path | None
mdbook
mdbook: dict[str, Any] = dataclasses.field(default_factory=dict)
Extra book.toml content for the mdbook engine (deep-merged into the generated
config, e.g. output.html.default-theme). A preprocessor.admonish entry switches
admonitions to the mdbook-admonish syntax.
project_dir
project_dir: pathlib.Path = dataclasses.field(default_factory=pathlib.Path.cwd)
Root folder of the project (contains mkdocs.yml / pyproject.toml).
render_by_default
render_by_default: bool = True
Render generated pages with the MkNodes Jinja environment.
repo_path
repo_path: str = '.'
Repository to build docs for (local path or remote URL).
resolved_docs_dir
resolved_docs_dir: pathlib.Path
resolved_generated_dir
resolved_generated_dir: pathlib.Path
show_page_info
show_page_info: bool = False
Append a collapsible box with build info to every page.
site_config
site_config: dict[str, Any] = dataclasses.field(default_factory=dict, repr=False)
The loaded site config (INHERIT resolved, custom tags preserved).
site_dir
site_dir: str | None = None
Output folder for the HTML build (default: the site config’s site_dir).
sphinx
sphinx: dict[str, Any] = dataclasses.field(default_factory=dict)
conf.py settings for the sphinx engine: theme (html_theme, default furo),
extensions (added to myst_parser / sphinx_design); any other key becomes a
conf.py variable (e.g. html_theme_options, suppress_warnings).
strict
strict: bool = False
Fail the build if it reported problems (build diagnostics).
Counted are: nodes which failed to get created in templates, failing /// mknodes
blocks and python exec="true" blocks (they render their error into the page),
broken code fences and unresolved [title][identifier] references. Without strict
mode they get logged as warnings. Also passed to the engine (zensical build --strict).
theme_config
theme_config: dict[str, Any]
__init__
def __init__(project_dir: pathlib.Path = pathlib.Path.cwd(), config_file: pathlib.Path | None = None, build_fn: str = paths.DEFAULT_BUILD_FN, kwargs: dict[str, Any] = dict(), repo_path: str = '.', clone_depth: int = 100, show_page_info: bool = False, render_by_default: bool = True, global_resources: bool = True, strict: bool = False, flavor: str | None = None, docs_dir: str | None = None, generated_dir: str | None = None, lock_file: str = 'mknodes.lock', inputs_mode: str = 'live', generated_config: str = GENERATED_CONFIG, site_dir: str | None = None, mdbook: dict[str, Any] = dict(), docsify: dict[str, Any] = dict(), sphinx: dict[str, Any] = dict(), jinja_engine: str | None = None, jinja_loaders: list[dict[str, Any]] | None = None, jinja_extensions: list[str] | None = None, jinja_block_start_string: str | None = None, jinja_block_end_string: str | None = None, jinja_variable_start_string: str | None = None, jinja_variable_end_string: str | None = None, site_config: dict[str, Any] = dict()) -> None
get_builder
def get_builder() -> Callable[..., Any]
Return the build function with the configured kwargs bound.
get_jinja_config
def get_jinja_config() -> jinjarope.EnvConfig
load
def load(project_dir: str | os.PathLike[str] | None = None, config_file: str | os.PathLike[str] | None = None, **overrides: Any) -> GeneratorSettings
Load settings for given project.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
project_dir | str | os.PathLike[str] | None | Project root (default: cwd, or the folder of config_file) | None |
config_file | str | os.PathLike[str] | None | Site config to read (default: mkdocs.yml in the project dir) | None |
overrides | Any | Explicit setting overrides (None values are ignored) | {} |
Page info
Code for this page
mknodes.manual.site._
@nav.route.page("Configuration", hide="toc")
def _(page: mk.MkPage):
page += mk.MkTemplate("site/configuration.jinja")
page += mk.MkDocStrings(
"mknodes.site.settings.GeneratorSettings",
show_root_toc_entry=False,
show_if_no_docstring=True,
heading_level=4,
show_bases=False,
show_source=False,
)
Resources
Resources(css=[],
markdown_extensions={},
plugins=[],
js=[],
assets=[],
packages=[])
Metadata
created:
source_filename: /home/runner/work/mknodes/mknodes/src/mknodes/manual/site/__init__.py
source_function: _
source_line_no: 21
hide:
- toc
title: Configuration